var app = new Vue({
    el: "#xp-wrapper",
    data:{
        oldManId: "",
        time:'',
        dailyLifeList:[]
    },
    mounted: function () {
        this.oldManId=getUrlParam("id");
        this.getDailyLifeByDate(this.oldManId,this.time);
    },
    methods: {
        getDailyLifeByDate:function (id,time) {
            dailyLifeList (id,time);
        }
    }
});
function dailyLifeList (oldManId,time){
    let data=new URLSearchParams();
    data.append("oldManId",oldManId);
    data.append("time",time);
    axios({
        method: 'post',
        url: "/yly-api/user/dailyLife",
        data:data,
        headers:{"token":localStorage.token}
    }).then((ins) => {
        let nhDto = ins.data;
        let dailyLifeList = nhDto.data;
        if (nhDto.code == 200) {
            console.log(dailyLifeList);
            app.dailyLifeList = dailyLifeList;
        } else if (nhDto.code == 500) {
            location.href = "/500.html";
        }
    }).catch(error=>{
        console.log(error.response.status);
        if (error.response.status==401){
            alert("请先登录!");
            location.href="index.html";
        }else if (error.response.status==403){
            alert("用户已过期，请重新登录！");
            localStorage.token=null;
            location.href="index.html";
        }
    });
};
function getUrlParam(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r!=null) return unescape(r[2]); return null;
}